﻿using System;
using System.Configuration;
using System.Text;
using System.Web;
using _5E.Infrastructure.Logging;
using WholesaleOnline.Controller;

namespace WholesaleOnline.WebUI
{
    public class Global : HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            StructureMapBootstrapper.Bootstrap();
            MySession.Timeout = Convert.ToInt32(ConfigurationManager.AppSettings["session_timeout"]);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            StringBuilder log = new StringBuilder()
                .Append("Message:").AppendLine()
                .AppendFormat("    {0}", ex.Message).AppendLine()
                .Append("Source:").AppendLine()
                .AppendFormat("    {0}", ex.Source).AppendLine()
                .Append("StackTrace:").AppendLine()
                .Append(ex.StackTrace);
            LoggingFactory.Logger.Log(log.ToString());
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}